<?xml version="1.0" encoding="utf-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:com="http://java.sun.com/jsf/composite/componentes"
	xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="/templates/layout.xhtml">
	<ui:include src="cadastro.xhtml" />

	<h2><h:outputText value="#{appMessages['condicoesClimaticas.titulo']}" /></h2>

	<h:form id="formCondicoesClimaticas">
		<p:toolbar id="tbCondicoesClimaticas" rendered="#{restrictions.cadastro}">
			<p:toolbarGroup>
				<p:commandButton 
					id="cadastrar"
					value="#{appMessages['condicoesClimaticas.cadastrar']}"
					action="#{condicoesClimaticasBean.cadastrarCondicaoClimatica()}"
					oncomplete="modalCadastro.show();"
					update=":modalCadastro"/>
			</p:toolbarGroup>
		</p:toolbar>
		
		<p:messages id="msgsCondicoesClimaticas"/>
		
		<p:confirmDialog
			header="#{appMessages['condicoesClimaticas.remover.titulo']}"
			message="#{appMessages['condicoesClimaticas.remover.mensagem']}"
			widgetVar="confirmacaoRemover"
			rendered="#{restrictions.cadastro}">
			<p:commandButton
				id="sim"
				value="#{messages['resposta.sim']}"
				action="#{condicoesClimaticasBean.removerCondicaoClimatica()}"
				update="msgsCondicoesClimaticas dtCondicoesClimaticas"
				oncomplete="confirmacaoRemover.hide();" />
			<p:commandButton id="nao" value="#{messages['resposta.nao']}" onclick="confirmacaoRemover.hide();"/>
		</p:confirmDialog>
		
		<p:dataTable
			id="dtCondicoesClimaticas"
			value="#{condicoesClimaticasBean.condicoesClimaticas}"
			var="condicaoClimatica"
			paginator="true"
			paginatorAlwaysVisible="false"
			rows="10">
			
			<!-- Condição Climática -->
			<p:column headerText="#{appMessages['condicoesClimaticas.condicaoClimatica']}">
				<h:outputText value="#{condicaoClimatica.nome}" />
			</p:column>
			
			<!-- Ação -->
			<p:column rendered="#{restrictions.cadastro}">
				<p:commandButton 
					icon="ui-icon-pencil"
					title="#{appMessages['condicoesClimaticas.alterar']}"
					action="#{condicoesClimaticasBean.carregarCondicaoClimatica()}"
					oncomplete="modalCadastro.show();"
					update=":modalCadastro" />
					
				<p:commandButton 
 					icon="ui-icon-close"
					title="#{appMessages['condicoesClimaticas.remover']}"
					action="#{condicoesClimaticasBean.carregarCondicaoClimatica()}"
					oncomplete="confirmacaoRemover.show();"
					rendered="#{restrictions.cadastro}" />
			</p:column>
		</p:dataTable>
	</h:form>
</ui:composition>
</html>